import Vue from 'vue'
import Vuex from 'vuex'
import persist from "vuex-persistedstate"

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 购物车存储的数据
    pic: [],
    // 存储的id
    users: [],
    shopss:[]
  },
  getters: {

  },
  mutations: {
    shops(state,data){
      state.shopss=data
    },
    picss(state, payload) {
      state.pic = payload
      console.log(state.pic,'22222')
    },
    // 登录vuex中的数据
    setuser(state, payload) {
      state.users = payload
      console.log(state.users, 'users')
    },

  },
  actions: {
    // 退出登录
    cleanLogin({ commit }) {
      commit("setuser", "")
      localStorage.removeItem("vuex")
    }
  },
  modules: {
  },

  plugins: [
    new persist({
      storage: window.localStorage
    })
  ]
})
